﻿namespace Core.Aria2c
{
    #region 全局信息
    public class Aria2cGlobalStatus
    {
        public string id { get; set; }
        public string jsonrpc { get; set; }
        public Aria2cGlobalStatusResult result { get; set; }
    }

    public class Aria2cGlobalStatusResult
    {
        /// <summary>
        /// 下载速度
        /// </summary>
        public string downloadSpeed { get; set; }
        /// <summary>
        /// 活动中的任务数量
        /// </summary>
        public string numActive { get; set; }
        /// <summary>
        /// 已停止的任务数量
        /// </summary>
        public string numStopped { get; set; }
        public string numStoppedTotal { get; set; }
        /// <summary>
        /// 等待中的任务数量
        /// </summary>
        public string numWaiting { get; set; }
        /// <summary>
        /// 上传速度
        /// </summary>
        public string uploadSpeed { get; set; }
    }
    #endregion

}

#region 添加url下载
// <自动生成 />
//
// 要解析此JSON数据，请添加NuGet "Newtonsoft.Json"，然后执行以下操作：
// 
//      using Core.Aria2c;
//
//      var aria2cAddUri = Aria2CAddUri.FromJson(jsonString);

namespace Core.Aria2c
{

    using System.Globalization;
    using Newtonsoft.Json;
    using Newtonsoft.Json.Converters;

    public partial class Aria2cAddUri
    {
        /// <summary>
        /// aria2c任务id
        /// </summary>
        [JsonProperty("id")]
        public string Id { get; set; }

        /// <summary>
        /// jsonrpc版本
        /// </summary>
        [JsonProperty("jsonrpc")]
        public string Jsonrpc { get; set; }

        /// <summary>
        /// 返回的 gid 
        /// </summary>
        [JsonProperty("result")]
        public string Result { get; set; }
    }

    public partial class Aria2cAddUri
    {
        public static Aria2cAddUri FromJson(string json) => JsonConvert.DeserializeObject<Aria2cAddUri>(json, Core.Aria2c.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this Aria2cAddUri self) => JsonConvert.SerializeObject(self, Core.Aria2c.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
        {
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
            DateParseHandling = DateParseHandling.None,
            Converters =
            {
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
            },
        };
    }
}

#endregion
